package org.stone.project.captcha.service.impl;

import com.google.code.kaptcha.Producer;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.stone.project.captcha.pojo.dto.CaptchaDto;
import org.stone.project.captcha.service.CaptchaService;

import java.awt.image.BufferedImage;

@Service
public class CaptchaServiceImpl implements CaptchaService {
    @Autowired
    private Producer producer;

    @Override
    public CaptchaDto getCodeImg(){
        CaptchaDto captchaDto = new CaptchaDto();
        captchaDto.setCode(producer.createText());
        captchaDto.setImg(producer.createImage(captchaDto.getCode()));
        return captchaDto;
    }
}
